
var fs = require('fs');
let path = require('path');
let PUBLIC_PATH = path.resolve(__dirname, '../../public');

let getFileData = function run (path) {
    return new Promise(async (resolve, reject) => {
        try {
            fs.readFile(PUBLIC_PATH + path, 'utf-8', (err, data) => {
                if (err) {
                    console.log('fs.readFile err: ', err);
                    reject('fs.readFile err: ' + err);
                }
                resolve(data);
            });
        } catch (err) {
            reject(err);
        }
    });
};

exports.getFileData = getFileData;